/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package sda.levelup.ann;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Дима
 */
public class MyAnnMech<T>
{
    
    public T makeInstance(Class<T> objClass){
        T example = null;
        if(objClass.isAnnotationPresent(MyAnnotation.class)){
            try {
                MyAnnotation ma = objClass.getAnnotation(MyAnnotation.class);
                example = objClass.getConstructor(String.class, int.class, String.class).newInstance(ma.getName(),ma.getId(),ma.getSomething());
            }
            catch (Exception ex) {
                ex.printStackTrace();
            }          
           
        }
        else {
            throw new IllegalArgumentException();
        } 
        return example;
    }
}
